*** Please adjust directory! ***
 
cd "/Users/flheeb/Dropbox (CSP)/Scope Insensitivity/04 Analysis/1_Replication_Code/1_Private_Investors_Main_Experiment"

capture log close
log using "log.log", replace
clear
set more off

*** Install packages ***

*ssc install logout
*ssc install winsor2
*ssc install estout
*ssc install stripplot


*** Load dataset ***

use "Pseudo_Dataset.dat", replace


*** Create labels (corresponding to variable names in Table A.4) ***

* Main variables, as described in Table A.4

label var RiskExp "Risk expectations"
label var ReturnExp "Return expectations"
label var Feeling "Positive emotions"
label var ImpactExp "Perceived investment impact"
label var ImpactRelevance "General relevance impact"
label var LevelRelevance "General relevance impact level"
label var co2_price "Estimated cost of saving 1 ton of CO2"
label var pref_risk "Risk preferences"
label var pref_time "Time preferences"
label var pref_altruism "Altruism"
label var ClimateProblem "Climate awareness"
label var Female "Female"
label var age "Age"
label var Income "Income"
label var NetWorth "Net worth"
label var Education "Highest education"
label var InvestKnow "Investment knowledge"

* Additional supporting variables, with description

label var HighImpact "Impact treatment" // Zero for the LowImpact treatment and one for the HighImpact treatment.
label var treatment "Impact treatment" // String variable describing the impact treatment.
label var ShareSI "Sustainable investment preference" // Zero for investors choosing the conventional investment in the initial, cost-neutral investment decision and one for investors choosing the sustainable investment.
label var control_failed "Disagreement with WTP" // Zero for investors who confirm the elicitated WTP, one for investors who disagree.
label var elicitation_repeated "Disagreement with WTP" // Zero for investors who do not repeat the WTP elicitation, one for investors who do.
label var HighIncome "High income" // Dummy variable indicating stated income is equal to or above the median.
label var UntoldIncome "Income not disclosed" // Dummy variable indicating that a participant did not disclose their income.
label var HNWI "High net worth" // Dummy variable indicating stated net worth is equal or above the median.
label var UntoldNW "Net worth not disclosed" // Dummy variable indicating that a participant did not disclose their net worth.
label var HigherEdu "Higher education" // Dummy variable indicating that an investor stated to have a higher education degree.
label var DesignB "Sustainable investment righthand" // Dummy variable indicating that the sustainable investment option is placed as the righthand option (placing is randomized).
label var Male "Male" // Dummy variable indicating male gender.


*** Drop observations ***

* Drop investors who do not think climate change is a problem

drop if ClimateProblem < 0
 
* Drop participant who do not agree with the elicited WTP and are not willing to repeat elicitation

drop if control_failed == 1 & elicitation_repeated == 0


*** Winsorize WTP and cost estimates at 5% & 95% level ***

winsor2 WTP, replace cuts(5 95)
winsor2 co2_price, replace cuts(5 95)


*** Generate relative WTP per ton of CO2 ***

gen WTP_CO2 = WTP / 5000 * 1000 if treatment == "High Impact"
replace WTP_CO2 = WTP / 500 * 1000 if treatment == "Low Impact"
label var WTP_CO2 "WTP/tCO\textsubscript{2}"


*** Save labeled, cleaned and winsorized dataset ***

save "Dataset_labeled.dat", replace


*** Descriptives (Table 1 and Table 2) ***

sort treatment
by treatment: summarize(WTP WTP_CO2 RiskExp ReturnExp Feeling ImpactExp co2_price pref_risk pref_time pref_altruism ClimateProblem Female age Income NetWorth Education InvestKnow ImpactRelevance LevelRelevance)


*** Regressions ***

** WTP per ton of CO2 <-> Feelings and Cost Estimates (Table 8)

* Without controls:

reg WTP_CO2 Feeling co2_price HighImpact
estimates store R1

* Controlling for demographics:

reg WTP_CO2 Feeling co2_price HighImpact InvestKnow Female Male age HigherEdu HighIncome UntoldIncome HNWI UntoldNW 
estimates store R2

esttab R1 R2 using Reg_WTP_CO2_Feeling_Price.rtf, replace r2 se label scalars(F) 
esttab R1 R2 using Reg_WTP_CO2_Feeling_Price.tex, replace r2 se label scalars(F)
estimates clear


*** WTP <-> Order of investments (Table A.1)

reg WTP DesignB HighImpact
estimates store R1
reg WTP DesignB HighImpact c.DesignB#c.HighImpact
estimates store R2
esttab R1 R2 using Reg_WTP_Design.rtf, replace r2 se label scalars(F)
esttab R1 R2 using Reg_WTP_Design.tex, replace r2 se label scalars(F)
estimates clear



** WTP <-> Expectations (Table A.5)

* Without controls:

reg WTP RiskExp ReturnExp HighImpact
estimates store R1

* Controlling for demographics:

reg WTP RiskExp ReturnExp HighImpact InvestKnow Female Male age HigherEdu HighIncome UntoldIncome HNWI UntoldNW 
estimates store R2
esttab R1 R2 using Reg_WTP_Expectations.rtf, replace r2 se label scalars(F)
esttab R1 R2 using Reg_WTP_Expectations.tex, replace r2 se label scalars(F)
estimates clear


*** Non-parametric test ***

* Testing for the differences between treatmens (Mann–Whitney U tests, Table 1, Table 2 and Chapter 2)

logout, save(ranksum_WTP_Impact) replace: ranksum WTP, by(treatment)
logout, save(ranksum_WTP_CO2_Impact) replace: ranksum WTP_CO2, by(treatment)
logout, save(ranksum_ShareSI_Impact) replace: ranksum ShareSI, by(treatment)
logout, save(ranksum_ImpactExp_Impact) replace: ranksum ImpactExp, by(treatment)
logout, save(ranksum_Feeling_Impact) replace: ranksum Feeling, by(treatment)
logout, save(ranksum_RiskExp_Impact) replace: ranksum RiskExp, by(treatment)
logout, save(ranksum_ReturnExp_Impact) replace: ranksum ReturnExp, by(treatment)
logout, save(ranksum_ImpactRelevance_Impact) replace: ranksum ImpactRelevance, by(treatment)
logout, save(ranksum_LevelRelevance_Impact) replace: ranksum LevelRelevance, by(treatment)
logout, save(ranksum_co2_price) replace: ranksum co2_price, by(treatment)
logout, save(ranksum_pref_risk_Impact) replace: ranksum pref_risk, by(treatment)
logout, save(ranksum_pref_time_Impact) replace: ranksum pref_time, by(treatment)
logout, save(ranksum_pref_altruism_Impact) replace: ranksum pref_altruism, by(treatment)
logout, save(ranksum_Female_Impact) replace: ranksum Female, by(treatment)
logout, save(ranksum_age_Impact) replace: ranksum age, by(treatment)
logout, save(ranksum_Income_Impact) replace: ranksum Income, by(treatment)
logout, save(ranksum_NetWorth_Impact) replace: ranksum NetWorth, by(treatment)
logout, save(ranksum_Education_Impact) replace: ranksum Education, by(treatment)
logout, save(ranksum_InvestKnow_Impact) replace: ranksum InvestKnow, by(treatment)
logout, save(ranksum_ClimateProblem_Impact) replace: ranksum ClimateProblem, by(treatment)


* Testing for the differences between variables within subject (Wilcoxon signed-rank test, Section 2.1.2)

logout, save(signrank_ImpactImportant_YesVsHowmuch) replace: signrank ImpactRelevance = LevelRelevance


*** Plots ***

* Distribitional plot WTP (Figure A.6)

stripplot WTP, over(HighImpact) stack vertical yla(, ang(h)) height(0.7) box(barw(0.08)) pctile(10) boffset(-0.16) width(5) graphregion(fcolor(white) lcolor(white)) ytitle(WTP (€), size(medlarge) margin(medsmall)) xla(0 `" "Low Impact" "(0.5 tCO{subscript:2})" "' 1 `" "High Impact" "(5 tCO{subscript:2})" "', labsize(medlarge) tlength(0) labgap(5)) yla(0(50)150, labsize(medlsmall)) xtitle("") note("Boxes show 10, 25, 50, 75 and 90 percentiles.", position(6) size(medsmall) margin(medsmall))
graph export "Distribution_WTP.pdf", as(pdf) replace

* Bar chart WTP (Figure 3 Panel A)

use "Dataset_labeled.dat", clear
statsby, by(HighImpact) : ci means WTP 
gen seu = mean + se
gen sel = mean - se

separate mean, by(HighImpact == 1)

twoway (bar mean1 HighImpact, barw(0.85) xsize(*0.7) bfcolor("18 96 104*0.66") blcolor("18 96 104") lwidth(1)) ///
 (bar mean0 HighImpact, barw(0.85) bfcolor("238 121 73*0.66") blcolor("238 121 73") lwidth(1))|| ///
rcap lb ub HighImpact, ///
legend(off) blcolor(black) graphregion(fcolor(white) lcolor(white)) ///
xla(0 `" "Low Impact" "(0.5 tCO{subscript:2})" "' 1 `" "High Impact" "(5 tCO{subscript:2})" "', labsize(medlarge) tlength(0) labgap(5)) xtitle("") xscale(range(-0.5 1.5)) ///
yla(0(10)60, labsize(medlsmall)) yscale(range(0 60) noextend) ytitle(Mean WTP (€), size(medlarge) margin(medsmall)) ///
plotregion(margin(b=0)) lpattern(dash) note(95% confidence intervals displayed, position(6) size(medsmall) margin(medsmall))

graph export "BarChart_WTP_Impact.pdf", as(pdf) replace

* Bar chart WTP per ton of CO2 (Figure 3 Panel B)

use "Dataset_labeled.dat", clear
statsby, by(HighImpact) : ci means WTP_CO2 
gen seu = mean + se
gen sel = mean - se

separate mean, by(HighImpact == 1)

twoway (bar mean1 HighImpact, barw(0.85) xsize(*0.7) bfcolor("18 96 104*0.66") blcolor("18 96 104") lwidth(1)) ///
 (bar mean0 HighImpact, barw(0.85) bfcolor("238 121 73*0.66") blcolor("238 121 73") lwidth(1))|| ///
rcap lb ub HighImpact, ///
legend(off) blcolor(black) graphregion(fcolor(white) lcolor(white)) ///
xla(0 `" "Low Impact" "(0.5 tCO{subscript:2})" "' 1 `" "High Impact" "(5 tCO{subscript:2})" "', labsize(medlarge) tlength(0) labgap(5)) xtitle("") xscale(range(-0.5 1.5)) ///
yla(0(20)100, labsize(medlsmall)) yscale(range(0 100) noextend) ytitle(Mean WTP/Impact (€/tCO{subscript:2}), size(medlarge) margin(medsmall)) ///
plotregion(margin(b=0)) lpattern(dash) note(95% confidence intervals displayed, position(6) size(medsmall) margin(medsmall))

graph export "BarChart_WTP_CO2_Impact.pdf", as(pdf) replace


